<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <link rel="shortcut icon" type="image/x-icon" href="assets/img/favicon.ico">
    <title>Preclinic - Medical & Hospital - Bootstrap 4 Admin Template</title>
    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/style.css">
    <!--[if lt IE 9]>
		<script src="assets/js/html5shiv.min.js"></script>
		<script src="assets/js/respond.min.js"></script>
	<![endif]-->
</head>

<body>
            <div class="content">
                <div class="row">
                    <div class="col-sm-5 col-5">
                        <h4 class="page-title">假期 2018</h4>
                    </div>
                    <div class="col-sm-7 col-7 text-right m-b-30">
                        <a href="add-holiday.html" class="btn btn-primary btn-rounded"><i class="fa fa-plus"></i> 新增假期</a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="table-responsive">
                            <table class="table table-striped custom-table mb-0">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>名称</th>
                                        <th>日期</th>
                                        <th>天数</th>
                                        <th class="text-right">操作</th>
                                    </tr>
                                </thead>
                                <tbody id="holidays">                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
           
		<div id="delete_holiday" class="modal fade delete-modal" role="dialog">
			<div class="modal-dialog modal-dialog-centered">
				<div class="modal-content">
					<div class="modal-body text-center">
						<h3>Are you sure want to delete this Holiday?</h3>
						<div class="m-t-20"> <a href="#" class="btn btn-white" data-dismiss="modal">Close</a>
							<button type="submit" class="btn btn-danger">Delete</button>
						</div>
					</div>
				</div>
			</div>
		</div>
    <div class="sidebar-overlay" data-reff=""></div>
    <script src="assets/js/jquery-3.2.1.min.js"></script>
	<script src="assets/js/popper.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/jquery.slimscroll.js"></script>
    <script src="assets/js/moment.min.js"></script>
    <script src="assets/js/bootstrap-datetimepicker.min.js"></script>
    <script src="assets/js/app.js"></script>
	<!--json data-->
	<script type="text/javascript" src="json/holidays.json"></script>
	<script type="text/javascript">
	$(document).ready(function () {
		var nowDay = new Date();
		var year = nowDay.getFullYear(); //获取当前年
		var mon = nowDay.getMonth() + 1; //获取当前月
		var date = nowDay.getDate(); //获取当前日
		var time = year + "/" + mon + "/" + date;
		nowDay = new Date(time);
		
		var holidaysStr = "";
		for(var i = 0; i < holidays.length; i++){
			var firstDay = new Date(holidays[i].holidays[0].replace("-", "/").replace("-", "/"));
			if(firstDay < nowDay){		
				holidaysStr = holidaysStr + '<tr class="holiday-completed">';
			}else{	
				holidaysStr = holidaysStr + '<tr class="holiday-upcoming">';
			}
			holidaysStr = holidaysStr + '<td>'+ (i + 1) +'</td>';
			holidaysStr = holidaysStr + '<td>'+ holidays[i].name +'</td>';
			holidaysStr = holidaysStr + '<td>'+ holidays[i].holidays +'</td>';
			holidaysStr = holidaysStr + '<td>'+ holidays[i].total +'</td>';
			holidaysStr = holidaysStr + '<td class="text-right">';
			if(firstDay > nowDay){
				holidaysStr = holidaysStr + '<div class="dropdown dropdown-action">';
				holidaysStr = holidaysStr + '<a href="#" class="action-icon dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-ellipsis-v"></i></a>';
				holidaysStr = holidaysStr + '<div class="dropdown-menu dropdown-menu-right">';
				holidaysStr = holidaysStr + '<a class="dropdown-item" href="edit-holiday.html"><i class="fa fa-pencil m-r-5"></i> Edit</a>';
				holidaysStr = holidaysStr + '<a class="dropdown-item" href="#" data-toggle="modal" data-target="#delete_holiday"><i class="fa fa-trash-o m-r-5"></i> Delete</a>';
				holidaysStr = holidaysStr + '</div>';
				holidaysStr = holidaysStr + '</div>';
			}
			holidaysStr = holidaysStr + '</td>';
			holidaysStr = holidaysStr + '</tr>';
		}
		$("#holidays").html(holidaysStr);		
	});
	</script>
</body>

</html>